package demo4;

/**
 * Created with IntelliJ IDEA.
 * Description:多态介绍
 * User: 阿宾
 * Date: 2024-05-19
 * Time: 20:35
 */
class B {
    public B() {
        // do nothing
        func(); // 会调用子类的func
    }
    public void func() {
        System.out.println("B.func()");
    }
}


class D extends B {

    private  int num = 1;

    D() {
        super();
    }
    @Override
    public void func() {
        //0
        System.out.println("D.func() " + num);
    }
}
public class Test {
    public static void main(String[] args) {
        D d = new D();

    }
}
